var express = require('express')
const multer = require('multer')



// 设置上传的目录
const upload = multer({
    dest: './uploads/'
})
var router = express.Router()

// 导入控制器模块
const IndexController = require('../controller/IndexController.js')
const CateController = require('../controller/CateController.js')
const ArtController = require('../controller/ArtController.js')
const UserController = require('../controller/UserController.js')
const query = require('../model/query.js')

// 后台首页
router.get('/', IndexController.index)
router.get('/systemData', IndexController.systemData)
// 展示分类列表页面
router.get('/catelist', CateController.index)
router.get('/artlist', ArtController.index)
// 后台登录页
router.get('/login', IndexController.login)
router.get('/test', IndexController.test)
router.get('/apiData', IndexController.apiData)

// 分类列表数据接口
router.get('/cateData', CateController.cateData)

// 分类添加
router.get('/addCate',CateController.addCate)
router.post('addList',CateController.addList)

// 编辑分类的接口  
router.post('/updCateData', CateController.updCateData)

// 删除分类数据接口
router.post('/deleteCate', CateController.deleteCate)

// 登录接口
router.post('/userLogin', UserController.userLogin)

// 登出接口
router.post('/userLogout', UserController.userLogout)

// 更新用户信息
router.post('/updUserInfo', UserController.updUserInfo)

// 更新用户头像
router.post('/avatar', upload.single('file'), UserController.avatar)

// 统计分类文章总数
router.get('/cateCount', CateController.cateCount)

module.exports = router;